package net.sourceforge.openclixml;

import net.sourceforge.openclixml.environment.IEnvironment;

import org.w3c.dom.Document;

import java.util.Map;


/**
 * Each clixml element is evaluatable and so an IEvaluator.
 * @version $Revision: 39 $
 * @author dominikjungo
 *
 * Last changed: $Date: 2008-01-22 21:38:51 +0100 (Tue, 22 Jan 2008) $
 * The License for this file can be found in doc/Licenses/license-OpenCliXML.txt
 */
public interface IEvaluator {
    /**
     * Evaluates the element by executing the delegate _eval method and assurres then that the success attribute is set.
     * @param environment The environment containing the variable definitions.
     * @param systemUnderTest The documents that are tested by this expression.
     * @return true if the subformula represented by this element and it's subtree evaluated to true. False otherwise.
     * @throws net.sourceforge.openclixml.EvaluationFailedException if the evaluation fails for some reason. This does not mean that the evaluated document is not clixml vlid, but rather that there is something wrong and validation cannot be continued.
     */
    boolean eval(IEnvironment<String, String> environment,
        Map<String, Document> systemUnderTest) throws EvaluationFailedException;

    /**
     * The element implementing this interface represents a subformula and this method evaluates the value of this formula. This method is a delegatee of the eval method.
     * @param environment The environment containing the variable definitions.
     * @param systemUnderTest The documents that are tested by this expression.
     * @return true if the subformula represented by this element and it's subtree evaluated to true. False otherwise.
     * @throws net.sourceforge.openclixml.EvaluationFailedException if the evaluation fails for some reason. This does not mean that the evaluated document is not clixml vlid, but rather that there is something wrong and validation cannot be continued.
     */
    boolean evalDelegated(IEnvironment<String, String> environment,
        Map<String, Document> systemUnderTest) throws EvaluationFailedException;
}
